package com.soushin.mvpdemo.Utils;

import android.content.Context;

import com.hjq.toast.ToastUtils;

import java.util.List;

import com.soushin.mvpdemo.App;

/**
 * 工具类
 *
 * @author SouShin
 * @time 2018/11/16 13:54
 */
public class AppUtils {

    /**
     * 退出登录
     * @param context
     * @return
     */
    private static long mExitTime;
    public static boolean doubleClickExit(Context context) {
        if ((System.currentTimeMillis() - mExitTime) > 2000) {
            ToastUtils.show("再按一次退出");
            mExitTime = System.currentTimeMillis();
            return false;
        }
        return true;
    }
    /**
     * 字符串判空
     *
     * @param str
     * @return
     */
    public static boolean isEmpty(String str) {
        return str == null || str.trim().length() == 0;
    }

    /**
     * 数组判空
     *
     * @param list
     * @return
     */
    public static boolean isEmpty(List list) {
        return list == null || list.size() == 0;
    }

    /**
     * 对象判空
     *
     * @param ob
     * @return
     */
    public static boolean isEmpty(Object ob) {
        return ob == null || isEmpty(ob.toString());
    }

    public static String getError(int code, String msg) {
        return msg + "：" + code;
    }
    public static int getColor(int color) {
        return App.getInstance().getResources().getColor(color);
    }
}
